package com.auxgroup.smarthome.business.controller;

import com.auxgroup.bridge.business.inner.vo.RegionVo;
import com.auxgroup.bridge.business.inner.vo.ThirdCascaderVo;
import com.auxgroup.smarthome.business.service.inner.AdministrativeDivisionInnerService;
import com.auxgroup.smarthome.web.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by lixiaoxiao on 17-9-15.
 */
@Api(tags = "省市相关")
@RestController
@RequestMapping("/region")
public class ConsumerAdministrativeDivisionController {
    @Autowired
    private AdministrativeDivisionInnerService administrativeDivisionInnerService;

    @ApiOperation(value = "获取省份")
    @GetMapping(value = "/provinces")
    public ApiResponse<List<RegionVo>> getAllProvince(){
        return administrativeDivisionInnerService.getAllProvince();
    }

    @ApiOperation(value = "获取城市")
    @GetMapping(value = "/provinces/{provinceId}/citys")
    public ApiResponse<List<RegionVo>> getCityByProvince(@PathVariable("provinceId") String provinceId){
        return administrativeDivisionInnerService.getCityByProvince(provinceId);
    }

    @ApiOperation(value = "获取区")
    @GetMapping(value = "/citys/{cityId}/districts")
    public ApiResponse<List<RegionVo>> getDistrictByCity(@PathVariable("cityId") String cityId){
        return administrativeDivisionInnerService.getDistrictByCity(cityId);
    }

    @ApiOperation(value = "获取级联省市区数据")
    @GetMapping(value = "/getThirdCasader")
    public ApiResponse<List<ThirdCascaderVo>> getThirdCasader(){
        return administrativeDivisionInnerService.getThirdCasader();
    }
}
